<?php

class Zendhlt_Form_Element_Birthday extends Zend_Form_Element_Xhtml {
	
    public $helper = "birthdayElement";
    protected $daynum = null;
    protected $monthnum = null;
    protected $yearnum = null;

    function setDayNum($num) {
        $this->daynum = $num;
        return $this;
    }

    function setMonthNum($num) {
        $this->monthnum = $num;
        return $this;
    }

    function setYearNum($num) {
        $this->yearnum = $num;
        return $this;
    }

    public function setValue($value) {
    	if (!is_array($value)) {
	    	$value = array(
	    					'yearnum' => substr($value, 0, 4),
	    					'monthnum' => substr($value, 5, 2),
	    					'daynum' => substr($value, 8, 2)
	    				  );
    	}
        if (is_array($value) && isset($value['yearnum'])
                && isset($value['monthnum']) && isset($value['daynum'])
           ) {
			$this->setDayNum($value['daynum'])
                 ->setMonthNum($value['monthnum'])
                 ->setYearNum($value['yearnum']);
        }
    }

    public function getValue() {
        if (! $this->daynum || ! $this->monthnum || ! $this->yearnum)
			return false;
        return $this->daynum .'-'. $this->monthnum .'-' . $this->yearnum;
	}
}